package com.ffapp.demo.bean;

import com.alibaba.fastjson.JSON;

import org.greenrobot.greendao.converter.PropertyConverter;

public class WarnMapProfileBeanConverter implements PropertyConverter<ProfileBean, String> {
    @Override
    public ProfileBean convertToEntityProperty(String databaseValue) {
        if (databaseValue == null) {
            return null;
        }
        // 先得获得这个，然后再typeToken.getType()，否则会异常
//        TypeToken<List<ProfileBean>> typeToken = new TypeToken<List<ProfileBean>>(){};
        return JSON.parseObject(databaseValue, ProfileBean.class);
//        return new Gson().fromJson(databaseValue, typeToken.getType());
    }

    @Override
    public String convertToDatabaseValue(ProfileBean entityProperty) {
            String sb = JSON.toJSONString(entityProperty);
            return sb;
    }
}